home *** CD-ROM | disk | FTP | other *** search
- Path: mayne.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character
- Date: 15 Apr 1996 16:14:20 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4kul8cINNeni@mayne.ugrad.cs.ubc.ca>
- References: <4kj66f$k0o@ren.cei.net> <4kmdsv$ojc@masala.cc.uh.edu> <4kmhpsINN7ak@keats.ugrad.cs.ubc.ca> <4ku99k$4ub@dawn.mmm.com>
- NNTP-Posting-Host: mayne.ugrad.cs.ubc.ca
-
- In article <4ku99k$4ub@dawn.mmm.com>, Chris Sonnack <cjsonnack@mmm.com> wrote:
- >Kazimir Kylheku (c2a192@ugrad.cs.ubc.ca) wrote:
- >
- >> Oops, I didn't notice that.
- >
- >Which, by your standards, enables us to call you all sorts of names, right?
- >
- >> So how is it right if it had undesired effects under certain conditions?
- >
- >Because sometimes you need a short, simple solution to a problem and can
- >pretty much guarentee "certain conditions" will not occur, or if they do,
- >catastrophic failure is okay in these rare cases. Not recommending this as
- >a way of working or designing, just pointing the potential DOES exist.
-
- Yeah. Those short solutions are OK. I mean, when I type a for ... command to
- the bourne shell, I don't care about doing everything so that it will not fail
- no matter what the files are named! I know I don't have files that have spaces
- in them or look like command-line options or start with , so I'm not about do
- to:
-
- for x in * ; do command -- "$x" ; done
-
- instead of
-
- for x in * ; do command $x ; done
-
- But in posting a sample Bourne script to a Newsgroup, I'd obey every rule I
- could think of. Or even in committing it to a script file.
-
- Then again, on c.l.c we are just more conscious of potential pitfalls, and are
- big on correctness. You can't decide for someone what level of solution is
- appropriate. It's not likely that some newbie is working on a safety-critical
- project, but I can't decide that on his behalf.
-
- No matter what code you write, you can never know 100% where it will end up, or
- how you, or someone else, will try to use it.
-
- >> And of course, *real* UNIX users don't put lines longer than 79 chars into
- >> a textfile anyway...
- >
- >Correct! ;-> (I know I //never// do!!)
-
- I'll be darned if I write lines of source longer than 79 columns.
-
-
- >> Humor me as to why it is necessary to retain a whole string of data just
- >> to then scan through it to find its length to remove the trailining
- >> newline, which was put there by a standard library function that already
- >> scanned the characters once to _find_ the newline in the first place.
- >
- >I found your solution was the most correct and elegant. In fact, it's a
- >very nice solution and you did solve the original problem in the best
- >way it could be solved.
-
- Well, almost.
-
- There are many unknowns: there is likely much more to the original problem than
- was specified in the posting. The program could well _require_ that the lines
- be retained in a buffer for some purpose that wasn't stated, in which case the
- simple filter is useless. But so is a solution that sets an arbitrary buffer
- size limit. A good program will read in a line of any size, and do something
- reasonable with null characters. One poster just contributed a universal ``get
- line'' routine that dynamically allocates the buffer, and can increase the size
- to read in any line. I think I will go back and do a thorough (though
- constructive) critique to look for anything troublesome that would take away
- from its generality. It's a good candidate for inclusion in the c.l.c. FAQ.
-
- It's programming like that which allows me to load a kernel image into the Vim
- editor, change a few bytes, and boot the result. Whereas SVR4 vi will choke
- due to its arbitrary limitations (Maximum 1024 characters per line? Groan...)
-
- >Doesn't change the fact that you're still rather a jerk.
-
- I just don't like it when dilettantes play expert on a world-wide newsgroup.
- Especially when they are UNIX guys---that makes me look bad. I've seen and
- heard people criticize UNIX for some of its old broken programs and security
- holes stemming from sloppy programming. Some of the attitudes behind this
- programming apparently prevail to this day.
-
- In any case, read my new temporary .sig
- --
- I'm not really a jerk, but I play one on Usenet.
-